package role

import "gitee.com/binny_w/gin_starter/core"

func checkApi(role, path string) uint8 {
	return check(role, path, true)
}

func check(role, path string, isApi bool) uint8 {
	x := "page"
	if isApi {
		x = "api"
	}
	bln, _ := core.Rbac.HasPermissionForRole(role, x, path)
	if bln {
		return 1
	}
	bln, _ = core.Rbac.Enforce(role, x, path)
	if bln {
		return 2
	}
	return 0
}
